package com.stars.home.vmodel

import android.app.Activity
import android.app.Application
import android.text.Editable
import android.text.TextUtils
import android.util.Log
import androidx.databinding.Bindable
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.stars.home.BR
import com.stars.home.activity.ApplyActivity
import com.stars.home.activity.BillActivity
import com.stars.home.activity.SurplusActivity
import com.stars.home.model.User
import com.stars.home.utils.net.NetEngine
import com.stars.home.view.SimpleTextWatcher
import com.trailer.base.base.BRepository
import com.trailer.base.base.BViewModel
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch
import kotlinx.coroutines.launch

class SurplusVModel(application: Application) : BViewModel<BRepository>(application) {


    var user=MutableLiveData<User>()


    fun toLook(){//查看明细

        UiSwitch.single(repository().context, BillActivity::class.java)


    }

    fun toApply(){
        //申请提现
        UiSwitch.bundle(repository().context,  ApplyActivity::class.java,
        B().putString("money",user.value?.technicianBalance).ok()
            )

    }


    fun getUserInfo(){
        viewModelScope.launch {
            var it=repository().lreq { NetEngine.service.getUser() }
            if(it.ok()) {
                user.value = it.data


            }
        }
    }

}
